package com.xiao.community.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xiao.community.entity.PintuanOrderEntity;
import com.xiao.community.service.PintuanOrderService;
import com.xiao.group.common.utils.PageUtils;
import com.xiao.group.common.utils.R;



/**
 * 
 *
 * @author 韩国涛
 * @email 2845009006@gmail.com
 * @date 2021-09-10 16:12:39
 */
@RestController
@RequestMapping("community/pintuanorder")
public class PintuanOrderController {
    @Autowired
    private PintuanOrderService pintuanOrderService;


    @RequestMapping("topintuanlist")
    public R topintuanlist(@RequestParam("goodsid")Integer goodsid){
        return pintuanOrderService.topintuanlist(goodsid);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = pintuanOrderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{pintuanOrderId}")
    public R info(@PathVariable("pintuanOrderId") Integer pintuanOrderId){
		PintuanOrderEntity pintuanOrder = pintuanOrderService.getById(pintuanOrderId);

        return R.ok().put("pintuanOrder", pintuanOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PintuanOrderEntity pintuanOrder){
		pintuanOrderService.save(pintuanOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PintuanOrderEntity pintuanOrder){
		pintuanOrderService.updateById(pintuanOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] pintuanOrderIds){
		pintuanOrderService.removeByIds(Arrays.asList(pintuanOrderIds));

        return R.ok();
    }

}
